using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using Caliburn.Micro;
using Updater.Wpf.Properties;
using Updater.Wpf.ViewModels;

namespace Updater.Wpf.SimpleApp.ViewModels
{
    public class ShellViewModel : Screen
    {
        private UpdaterViewModel updaterViewModel;
        public UpdaterViewModel UpdaterViewModel
        {
            get
            {
                return this.updaterViewModel;
            }
            private set
            {
                if (Equals(value, this.updaterViewModel))
                {
                    return;
                }
                this.updaterViewModel = value;
                this.NotifyOfPropertyChange(() => this.UpdaterViewModel);
            }
        }

        public string TheOtherContent { get; private set; }

        public ShellViewModel()
        {
            TheOtherContent = "Here is the other content of the application";
        }

        [UsedImplicitly]
        public void Load()
        {
            // The only thing you should adjust in the simplest case is subscribe to the application restart request
            this.UpdaterViewModel = new UpdaterViewModel();
            UpdaterViewModel.ApplicationRestartRequest += (sender, args) => this.TryClose();
        }
    }
}